<?php

namespace app\model;
use app\validate\User as UserValidate;

class User extends Common{
   
    //注册用的IP
    protected function setIpAttr(){
        return  request()->ip();    
     }
     public function setPasswordAttr($val)
     {
         return md5('hch'.sha1($val).'hcl');
     }

     
    // //注册添加处理
    // public function add($data)
    // {
    //     $validate=new UserValidate();
        
    // }   
    //编辑处理
    public function edit($data)
    {    
        $validate=new UserValidate();
        if (!$validate->scene('edit')->check($data) ) {
            return $this->message('400',$validate->getError());
        }
        $res=User::update($data,$data['id']);
        if($res){
            return $this->message('200','更改成功');
        }
    }

}